package com.marvels.approve.process.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.marvels.approve.manager.dto.OpinionDTO;
import com.marvels.approve.process.dto.LoanApplyCaseDTO;
import com.marvels.approve.process.service.IProcessService;
import com.marvels.common.dto.MarvelsResultDTO;
import com.marvels.common.exception.MarvelsBusinessException;
import com.marvels.common.exception.MarvelsErrorCode;
import com.marvels.common.utils.MarvelsLogUtil;


/**流程处理
 * @author hejie
 */
@RestController
@RequestMapping("approve/process/api")
public class ProcessControllerApi {

	
	@Autowired
	private IProcessService processService;
	
	/**获取退回app退回原因
	 * @author 娄凯琦
	 * @date 2018年9月27日  
	 * @param loanApplyCaseDTO
	 * @return
	 */
	@RequestMapping("getRefusedReason")
	@ResponseBody
	public MarvelsResultDTO getRefusedReason(@RequestBody LoanApplyCaseDTO loanApplyCaseDTO){
		try {
			List<OpinionDTO> opinionList = this.processService.queryRefusedReason(loanApplyCaseDTO);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(),MarvelsErrorCode.SUCCESS.getDesc(), opinionList);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error("ProcessControllerApi ProcessControllerApi",e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(),MarvelsErrorCode.FAIL.getDesc(), e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error("ProcessControllerApi ProcessControllerApi",e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(),MarvelsErrorCode.ERROR.getDesc(), null);
		}
	}
}
